using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace QLNS.Data
{
    public class HopDong_db
    {
        Services m_Ds = new Services();
        public HopDong_db() { }

        public DataTable DanhSachHopDong()
        {
            //OleDbCommand cmd = new OleDbCommand("SELECT * FROM HOPDONG");
            OleDbCommand cmd = new OleDbCommand("SELECT HD.ID AS ID,HD.LoaiHopDong,HD.NhanVien_ID,HD.Ho,HD.TenLot,HD.Ten,HD.TuNgay,HD.DenNgay FROM HOPDONG HD, LOAIHOPDONG LHD,NHANVIEN NV where HD.ID=LHD.ID and HD.LoaiHopDong=LHD.Name and HD.NhanVien_ID=NV.ID and HD.Ho=NV.Ho and HD.TenLot=NV.TenLot and HD.Ten=NV.Ten");
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataRow NewRow()
        {
            return m_Ds.NewRow();
        }

        public void Add(DataRow row)
        {
            m_Ds.Rows.Add(row);
        }

        public bool Save()
        {
            return m_Ds.ExecuteNoneQuery() > 0;
        }
        public DataTable TimTheoTen(string ten)
        {
            string sql = "SELECT * FROM NHANVIEN where Ten like '%" + ten + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataTable TimTheoMa(string id)
        {
            string sql = "SELECT * FROM NHANVIEN where ID like '%" + id + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }
    }
}
